file_name= input('文件名是：')
line_count=0                                        #算行数
with open(file_name,'r',encoding='ansi') as file: 
    for line in file:
        if len(line) > 1:
            line_count+=1

def getWords(filepath):                             #分离单词
    file = open(filepath)
    ascii_list=[]
    word1 = []
    for i in range(33,48,1):
        ascii_list.append(i)
    for i in range(58,65,1):
        ascii_list.append(i)
    for i in range(91,97,1):
        ascii_list.append(i)
    for i in range(123,127,1):
        ascii_list.append(i)
    while(file):
        line = file.readline()
        for i in line:
            if ord(i) in ascii_list:
                line = line.replace(i,' ')
        word1.extend(line.split())
        if (not line):          
            break
    return word1
        
word_count = len(getWords(file_name))              #去掉不符合的单词算单词数
wordlist = []
for i in getWords(file_name):
    wordlist.append(i)
lower = [item.lower() for item in wordlist]    
for i in lower:
    if ord(i[0]) < 65 or ord(i[0]) > 122:
        lower.remove(i)
def remove():
    ascii_list2=[]
    wordremove1=[]
    for i in range(32,127):
        ascii_list2.append(i)
    for i in lower:
        lenth=len(i)
        for j in range(lenth):
            if ord(i[j]) not in ascii_list2:
                i=i.replace(i[j],'+')
                wordremove1.append(i)
                break
            if j == (lenth-1):
                wordremove1.append(i)
    return wordremove1
word_2=[]
list1=remove()
for i in list1:
    if '+' not in i:
        word_2.append(i)
    

def getCharacters(filepath):                        #算字符数
    file = open(filepath)
    word1=[]
    while(file):
        character = file.read()
        word1.extend(character)
        if (not character):          
            break
    character_count=0
    for i in word1:
         if ord(i) < 256:
            character_count += 1
    return character_count


            
print('characters：',getCharacters(file_name))
print('words：',len(word_2))
print('lines：',line_count)

dic={}                                             #字典序打印频率前十位的单词
count = []

for each in word_2:
        if each in dic:
            dic[each]=dic[each]+1
        else:
            dic[each]=1
for i in sorted(dic.items(),key=lambda x:x[1],reverse=True):
    count.append(i)
count.sort()
if count != []:
    for i in range(min(10,len(count))):
        print(count[i])


                                                      
